# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2021年04月21日
"""
from win32com.client import Dispatch, constants, gencache

docx_path = './长恨歌/长恨歌3.docx'
pdf_path = './长恨歌/长恨歌3.pdf'
gencache.EnsureModule('{00020905-0000-0000-C000-000000000046}', 0, 8, 4)
wd = Dispatch("Word.Application")

doc = wd.Documents.Open(docx_path,ReadOnly=1)
doc.ExportAsFixedFormat(pdf_path,constants.wdExportFormatPDF,
                        Item=constants.wdExportDocumentWithMarkup,
                        CreateBookmarks=constants.wdExportCreateHeadingBookMarks)
